package cn.colorful.olympic.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import cn.colorful.olympic.R;
import cn.colorful.olympic.bean.GoldJsonBean;

public class GoldListViewAdapter extends BaseAdapter{
	
	private Context context;
	private List<GoldJsonBean> listRes;
	
	public GoldListViewAdapter(Context context,List<GoldJsonBean> list){
		this.context = context;
		this.listRes = list;
	}
	
	@Override
	public int getCount() {
		if(listRes!=null && listRes.size()>0){
			return listRes.size();
		}
		return 0;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return listRes.get(position);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final GoldListViewHolder holder;
		
		if (convertView == null) {
			holder = new GoldListViewHolder();
			LayoutInflater inflater = LayoutInflater.from(context);
			convertView = inflater.inflate(R.layout.gold_listview_item, null);
//			holder.imageViewIcon = (ImageView) convertView
//					.findViewById(R.id.image_item_icon);
			holder.countryName = (TextView) convertView
					.findViewById(R.id.tv_item_country);
			holder.gold = (TextView) convertView
					.findViewById(R.id.tv_item_gold);
			holder.silver = (TextView) convertView
					.findViewById(R.id.tv_item_sliver);
			holder.copper = (TextView) convertView
					.findViewById(R.id.tv_item_copper);
			holder.count = (TextView) convertView
					.findViewById(R.id.tv_item_count);
			convertView.setTag(holder);

			// 设置holder的值 根据position
			//设置图标
			
			
		} else {
			holder = (GoldListViewHolder) convertView.getTag();
		}
		return convertView;
	}
	
	private class GoldListViewHolder {
		public ImageView imageViewIcon;	// 图标
		public TextView countryName;// 国家名
		public TextView gold;// 推荐总数
		public TextView silver;//
		public TextView copper;
		public TextView count;
	}
	
	

}
